package main

import (
	"fmt"
	"io"
	"os"
	"strconv"
	"time"
)

func main() {
	err := CombineFile("sskCombine1.txt", "sskCombineOther.txt")
	fmt.Println("合并文件时判断有没有报错：", err)
	
	gid := Gid()
	fmt.Println("生成的gid值为：", gid)
	
	fmt.Println("新生成的gid值为：", gid)
	fmt.Println("新生成2的gid值为：", Gid())
}

func Gid() string {
	return strconv.FormatInt(time.Now().UnixNano(), 10)
}

func CombineFile(dst string, src string) error {
	sf, err := os.Open(src)
	if err != nil {
		return err
	}
	defer sf.Close()
	
	df, err := os.OpenFile(dst, os.O_RDWR|os.O_APPEND, 0666)
	if err != nil {
		return err
	}
	defer df.Close()
	
	_, err = io.Copy(df, sf)
	return err
}
